import java.util.Arrays;

class Student implements Comparable <Student> {
    public String name;
    public int age;
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
//    @Override
//    public int compareTo(Student o) {
//        return this.name.compareTo(o.name);
//    }
    @Override
    public int compareTo(Student o) {
        return this.age-o.age;
    }
    
    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}

public class Test{

    public static void main(String[] args) {
        Student[] students = new Student[3];
        Student student1 = new Student("张三",20);
        Student student2 = new Student("李四",23);
        Student student3 = new Student("王五",25);
        students[0] = student1;
        students[1] = student2;
        students[2] = student3;
        
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
        
//        if (student1.compareTo(student2) > 0) {
//            System.out.println("student1 > student2");
//        }else {
//            System.out.println("student1 < student2");
//        }
    }
}



//class Student {
//    public String name;
//    public int age;
//    public Student(String name, int age) {
//        this.name = name;
//        this.age = age;
//    }
//}
//
//public class Test{
//    public static void main(String[] args) {
//        Student student1 = new Student("张三",20);
//        Student student2 = new Student("李四",23);
//        if (student1.compareTo(student2) > 0) {
////        if (student1 < student2) {
//            System.out.println("student1 > student2");
//        }else {
//            System.out.println("student1 < student2");
//        }
//    }
//}
